<?php
require 'kernel/common.php';

$GLOBALS['smarty']->assign('titre_site', $setting['titre_site'] . ' - ' . $lang['Agence'] );
$GLOBALS['smarty']->display($fichier_theme_header, $fichier_theme_header);

$GLOBALS['smarty']->caching = 1;

if(!$GLOBALS['smarty']->isCached(get_template_file('agence.tpl'), 'agence_fr'))
{
    $agences = array();

    $Sql =$GLOBALS['db']->query("SELECT * FROM immo_agence ORDER BY nom");
    $a = $GLOBALS['db']->fetchAll($Sql);
    $count = 1;
     
    foreach($a as $Agence):
    
        if($Agence['photo'] != '')
    	{
    		if(is_file('upload/agences/' . $Agence['photo'])) 
                $Agence['photo_valide'] = 1;
    		else 
                $Agence['photo_valide'] = '0';
    	}
    	else $Agence['photo_valide'] = '0';
        
        array_push($agences, $Agence);
        
    	$count++;
        
    endforeach;
    
    $GLOBALS['smarty']->assign('lang', $lang);
    $GLOBALS['smarty']->assign('agences', $agences); 
    $GLOBALS['smarty']->assign('nb_agence', $count);   
}

$GLOBALS['smarty']->display(get_template_file('agence.tpl'), 'agence_fr');

$GLOBALS['smarty']->caching = 0;

require_once 'kernel/footer.php';
?>